import {createStore} from "vuex"

import moduleA from "./module/moduleA"
import moduleB from "./module/moduleB"

export default createStore({
    modules:{
        a:moduleA,
        b:moduleB
    },
    state:{
        count: 0
    },
    getters:{
        countAddFive: (state) => {
            return state.count + 5
        },
    countAddFiveAddTen: (state, getters) => {
        return getters.countAddFive + 10
    }
 },
    mutations:{
        add(state){
            state,count++
        },
        addPlayload(state,playload){
            state.count +=playload.num
        }
    },
    actions:{
        // addAction(context){
        //     // state,getters,commit,,,
        //     context,commit('add')
        // }
        addAction({commit}){
            commit('add')
        },
        asyncAddAction({commit}){
            setTimeout(() => {
                commit('add')
            },1000)
        },
        asyncAddployloadAction({commit},playload){
            setTimeout(() => {
                commit('addPlayload',playload)
            },1000)
        }
    }
})